<?php

$mName=isset($_GET['m'])?($_GET['m']):'home';
$cName=isset($_GET['c'])?($_GET['c']):'Match';
$aName=isset($_GET['a'])?($_GET['a']):'match';
//通过全局变量来控制访问路径
define('MODEL',$mName);
define('CONTROLLER',$cName);
define('ACTION',$aName);
//定义自动调用文件名
spl_autoload_register('first');

$arrList=array(
	'Model'=>'./framework/Model.class.php',
	'Controller'=>'./framework/Controller.class.php',
	'Factory'=>'./framework/Factory.class.php',	
	'Mysql'=>'./framework/Mysql.class.php',
	'Smarty'=>'./framework/lib/smarty/Smarty.class.php'	
	);
//自动调用函数
function first($className){
	global $arrList;
	if(array_key_exists($className,$arrList)){
		require $arrList[$className];		
	}elseif(substr($className,-10)=='Controller'){
		require './app/'.MODEL.'/'.substr($className,-10).'/'.$className.'.class.php';
	}elseif(substr($className,-5)=='Model'){
		require './app/'.MODEL.'/'.substr($className,-5).'/'.$className.'.class.php';
	}
}

$controller=$cName.'Controller';
$controllerName=$aName.'Action';
$C = new $controller();
$C->$controllerName();